{% extends 'users/base.html' %}
{% block head %}<title>文章管理</title>{% endblock head %}  
{% block content %}
<div class="container">
  <section class="hero is-primary is-bold">
    <div class="hero-body">
      <div class="container">
        <div class="level">
          <div class="level-left">
            <h1 class="title">文章列表</h1>
          </div>
          <div class="level-right">
            <a class="button" href="{% url 'users:user_profile' %}">
              <span class="icon">
                <i class="fas fa-arrow-left"></i>
              </span>
              <span>返回个人中心</span>
            </a>
          </div>
        </div>
      </div>
    </div>
  </section>

  <div class="box" style="padding: 50px 80px; margin: 50px auto">
    {% if posts %}
    <ul>
      {% for post in posts %}
      <li>
        <div class="box" style="margin-top: 15px;">
          <div class="level desc-container"> 
            <div class="level-left">
              <div class="desc-content">
                <h3><a href="#">{{ post.title }}</a></h3>
                <p>作者：{{ post.owner }}</p>
                <p>发布时间：{{ post.add_date }}</p>
                <p class="desc-truncated desc-wrap">{{ post.desc }}</p>
              </div>
            </div>
            <div class="level-right">
              <div class="buttons">
                <a href="{% url 'users:update_post' post.id %}" class="button is-primary">编辑</a>
                <a href="{% url 'users:delete_post' post.id %}" class="button">删除</a>
              </div>
            </div>
          </div>
        </div>
      </li>
      {% endfor %}
    </ul>
    {% else %}
    <p>还没有发布文章</p>
    {% endif %}
  </div>
</div>
{% endblock %}
